home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / message.zip / MESSAGE.ASC < prev    next >
Text File  |  1992-11-10  |  37KB  |  849 lines

  1.   0 /*
  2.   1 ╔════════════════════════════════════════════════════════════════════════════╗
  3.   2 ║                               MESSAGE MINDER                               ║
  4.   3 ║                                                                            ║
  5.   4 ║                     By Brian Hill           March, 1992                    ║
  6.   5 ║                                                                            ║
  7.   6 ║       Message minder is a TSR program which will display a message         ║
  8.   7 ║  from the serial port on the screen. The message is cleared when the       ║
  9.   8 ║  user presses any key. The format for sending a messge is as follows:      ║
  10.   9 ║  1) The com port on the sending machine should be set to 9600, N, 8, 1.    ║
  11.  10 ║  2) A message is started with a SOH character. <alt> 1 will generate.      ║
  12.  11 ║  3) A message is completed with a EOT character. <alt> 4 will generate.    ║
  13.  12 ║                                                                            ║
  14.  13 ║ *NOTE when the user enters the un-install command: message u  the program  ║
  15.  14 ║  will only un-install properly if it is the last TSR loaded.               ║
  16.  15 ║                                                                            ║
  17.  16 ╚════════════════════════════════════════════════════════════════════════════╝
  18.  17                                                                             */
  19.  18 #pragma check_stack( off )     // turn off stack checking
  20.  19 #pragma check_pointer( off )   // do not check for null pointers
  21.  20 #pragma pack(1)                // byte align data to conserve memory
  22.  21 
  23.  22 #include <string.h>
  24.  23 #include <stdlib.h>
  25.  24 #include < conio.h>
  26.  25 #include < stdio.h>
  27.  26 #include <  bios.h>
  28.  27 #include <   dos.h>
  29.  28 
  30.  29 #define SOH  1          // start of header
  31.  30 #define EOT  4          // end of transmit
  32.  31 #define ESC 27          // ASCII value of escape key
  33.  32 #define ENTER 13        // ASCII value for enter key
  34.  33 #define BACKSPACE 8     // ASCII value for backspace key
  35.  34 #define NORM_VID 7      // normal video attribute
  36.  35 
  37.  36 
  38.  37 /*
  39.  38 ╔════════════════════════════════════════════════════════════════════════════╗
  40.  39 ║             Interrupt routines and function pointers                       ║
  41.  40 ╚════════════════════════════════════════════════════════════════════════════╝
  42.  41                                                                             */
  43.  42 void (interrupt _far *oldclock)(void);  // old clock handler
  44.  43 void (interrupt _far *olddosok)(void);  // old dosok handler
  45.  44 void (interrupt _far *oldkeybd)(void);  // old keyboard handler
  46.  45 void  interrupt _far keybd(void);       // our keyboard handler
  47.  46 void  interrupt _far clock(void);       // our clock routine
  48.  47 void  interrupt _far dosok(void);       // our dosok handler
  49.  48 void  interrupt _far serial(void);      // Our serial port ISR
  50.  49 
  51.  50 
  52.  51 
  53.  52 
  54.  53 
  55.  54 /*
  56.  55 ╔════════════════════════════════════════════════════════════════════════════╗
  57.  56 ║           Functions our program will call when active                      ║
  58.  57 ╚════════════════════════════════════════════════════════════════════════════╝
  59.  58                                                                             */
  60.  59 void memputs(char x,char y,char *string,char attrib); // display string
  61.  60 void save_screen(void);                 // save user's screen in screen[]
  62.  61 void restore_screen(void);              // restore user's screen
  63.  62 void display_message(void);             // display our message to screen
  64.  63 void draw_border(int type);             // make a message border
  65.  64 void doit(void);                        // activate TSR
  66.  65 void memputs(char x, char y,char *string, char attrib);
  67.  66 void send_message(void);                // Get message and transmit
  68.  67 void display_message(void);             // show received message
  69.  68 void xmit_char(char ch);                // sent a character out COM 1
  70.  69 int  chk_xmit(void);                    // Is it OK to send a character?
  71.  70 int  mem_gets(char *szStr,int xyStrRow, int xyStrCol);  // get a string
  72.  71 void write_char(int x,int y,char ch,char attrib);       // write char at x,y
  73.  72 void goto_xy(int x, int y);                             // move cursor
  74.  73 void get_xy(int *x, int *y);            // get cursor pos -w- BIOS
  75.  74 void beep(void);                        // short "beep" thru PC's speaker
  76.  75 
  77.  76 void main();
  78.  77 void init(void);                        // set up program
  79.  78 int  check_install(int num);            // check if program resident
  80.  79 void interrupt _far un_install (void);  // pointer to un-install function
  81.  80 
  82.  81 /*
  83.  82 ╔════════════════════════════════════════════════════════════════════════════╗
  84.  83 ║                            Program data                                    ║
  85.  84 ╚════════════════════════════════════════════════════════════════════════════╝
  86.  85                                                                             */
  87.  86 char buffer[81];                        // our serial input buffer
  88.  87 char userscreen[481];                   // save user's screen here
  89.  88 int  port;                              // com1 port address
  90.  89 int  _far *keyboard_status;             // check if <ctrl> is pressed.
  91.  90 char _far *video = (char far *)0xB8000000;   // pointer to color video memory
  92.  91 char _far *mode  = (char far *)0x00400049;   // pointer to CRT video mode
  93.  92 
  94.  93 char _huge *tsrstack;                   // our stack space
  95.  94 char _huge *tsrbottom;                  // huge pointer to our PSP
  96.  95 char _huge *userstack;                  // user's stack space
  97.  96 
  98.  97 char string[] = {"_MESSAGE"};           // TSR signature
  99.  98 struct tsrinfo
  100.  99 {
  101. 100      char *signature;                   // pointer to TSR signature
  102. 101      void (interrupt _far *un_install_ptr)(void);   // pointer to un-install
  103. 102 
  104. 103 } transient, _huge *resident;
  105. 104 
  106. 105 
  107. 106 
  108. 107 
  109. 108 /*
  110. 109 ╔════════════════════════════════════════════════════════════════════════════╗
  111. 110 ║                             Flags                                          ║
  112. 111 ╚════════════════════════════════════════════════════════════════════════════╝
  113. 112                                                                             */
  114. 113 char _far request_to_run;               // Has message arrived?
  115. 114 char _far tsr_running;                  // Is menu displayed?
  116. 115 _segment(dosseg);                       //  Segment of inDos flag.
  117. 116 char _based(dosseg) *indos;             //  Based pointer to InDos flag.
  118. 117 char video_mode_flag;                   // Waiting for appropriate video mode?
  119. 118 
  120. 119 
  121. 120 /*
  122. 121 ╔════════════════════════════════════════════════════════════════════════════╗
  123. 122 ║                               Code                                         ║
  124. 123 ╚════════════════════════════════════════════════════════════════════════════╝
  125. 124                                                                             */
  126. 125 void main(int argc, char **argv)
  127. 126 {
  128. 127 
  129. 128  unsigned tsrsize;               // memory needed for residence
  130. 129  int i;                          // a scratch pad variable
  131. 130  char ch;
  132. 131 
  133. 132 /*
  134. 133     ╔═════════════════════════════════════════════════════════════════════╗
  135. 134     ║                    Claculate program size                           ║
  136. 135     ╚═════════════════════════════════════════════════════════════════════╝
  137. 136                                                                            */
  138. 137  _asm mov WORD PTR tsrstack[0], sp              // save our stack address
  139. 138  _asm mov WORD PTR tsrstack[2], ss
  140. 139  FP_SEG(tsrbottom) = _psp;                      // save PSP address
  141. 140  FP_OFF(tsrbottom) = 0;
  142. 141  tsrsize = ((tsrstack - tsrbottom) >> 4) + 1;   // calculate program size
  143. 142 
  144. 143 /*
  145. 144     ╔═════════════════════════════════════════════════════════════════════╗
  146. 145     ║                   Is the program already installed?                 ║
  147. 146     ╚════════════════════════